Skip to content

[flake8-annotations] Do not automatically set the return type to NoReturn when raising NotImplementedError#18927

Closed
danparizher wants to merge 1 commit intoastral-sh:mainfrom
danparizher:fix-18886
Closed

[flake8-annotations] Do not automatically set the return type to NoReturn when raising NotImplementedError#18927
danparizher wants to merge 1 commit intoastral-sh:mainfrom
danparizher:fix-18886

Conversation

@danparizher
Copy link
Contributor

Summary

Fixes #18886

Test Plan

@danparizher danparizher changed the title fix-18886 [ANN] automatically sets the return type to NoReturn to raise NotImplementedError Jun 24, 2025
@danparizher danparizher changed the title [ANN] automatically sets the return type to NoReturn to raise NotImplementedError [flake8-annotations] automatically sets the return type to NoReturn to raise NotImplementedError Jun 24, 2025
@danparizher danparizher changed the title [flake8-annotations] automatically sets the return type to NoReturn to raise NotImplementedError [flake8-annotations] Do not automatically set the return type to NoReturn when raising NotImplementedError Jun 24, 2025
@github-actions
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

}
}

fn raises_only_not_implemented_error(function: &ast::StmtFunctionDef) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unfortunate that we need to traverse the entire function again to determine if all of them were RaiseNotImplemented. Should we add a new Terminal::RaiseNotImplemented variant instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point—but the extra walk only happens when we’ve already determined the function is Terminal::Raise, so the cost is minimal. Extending Terminal with a RaiseNotImplemented would mix exception-specific semantics into what’s currently a pure control-flow enum and force every existing caller to handle a new case.

@danparizher
Copy link
Contributor Author

Going to close and redo this PR as it has been stale for a few months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANN201, ANN202, ANN205 automatically sets the return type to NoReturn to raise NotImplementedError

2 participants